package xin.yangshuai.basic01.hello;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Hello
 *
 * @author shuai
 * @date 2022/7/1
 */
public class Hello {

    public static void main(String[] args) {


        for (int i = 1; i < 10; i++) {
            for (int j = 1; j <= i; j++) {

                System.out.print(i + "*" + j + "=" + i * j + "\t");

            }
            System.out.println();
        }

        int num = 0;

        String str = "";

        for (int i = 1; i < 100; ) {
            num = num + i;

            i = i + 2;
        }

        //        System.out.print("当前i=" + i);
//        System.out.println("当前结果=" + num);
//        System.out.println("--------------------");
//        str = str + "+" + i;

        System.out.println(num);

        int add = 1;

        for (int i = 2000; i <= 2022; i = i + add) {
            if (i % 100 != 0) {
                if (i % 4 == 0) {
                    System.out.println(i);
                    add = 4;
                }
            } else {
                if (i % 400 == 0) {
                    System.out.println(i);
                }
            }
        }

        for (int i = 0; i < 1000; i++) {
            int j = i;
            while (j > 0) {
                int more = j % 10;
                if (more == 7) {
                    System.out.println(i);
                    break;
                }
                if (i % 7 == 0) {
                    System.out.println(i);
                    break;
                }
                j = j / 10;
            }
        }


        int count = 0;
        int a = 1;
        for (int i = 0; i < 10; i++) {

        }


        List<Object> objects = Collections.synchronizedList(new ArrayList<>());


        Hello hello = new Hello();
        int rabbitCount = hello.rabbit(0);
        System.out.println(rabbitCount);

        hello.sjx(20);

        hello.sjx1(10);

        hello.sjx2(10);
    }

    //新兔子 3年后生 老兔子 1年生

    //0 当前一个新兔子
    //3 三月后 生 1只
    //6 三月后


    public int rabbit(int year) {
        int count = 0;
        for (int i = year; i < 10; i++) {
            System.out.println("第" + i + "年新兔子");
            int newCount = rabbit(year + 3);
            count = count + newCount;
            count++;
        }
        return count;
    }


    public void sjx(int offset) {

        for (int i = 0; i < offset; i++) {
            System.out.print(" ");
        }
        System.out.print("*");
        System.out.println();
        offset--;
        int blank = 1;
        while (offset >= 0) {
            for (int i = 0; i < offset; i++) {
                System.out.print(" ");
            }
            System.out.print("*");
            for (int i = 0; i < blank; i++) {
                System.out.print(" ");
            }
            System.out.println("*");
            blank += 2;
            offset--;
        }

    }


    public void sjx1(int offset) {

        int i = 1;
        while (i > 0) {
            for (int j = 1; j < 18; j++) {


                for (int k = 1; k < j; k++) {


                    System.out.print("*");


                }


                System.out.print("*");

            }
            System.out.println();
            if (i < offset) {
                i++;
            } else {
                offset = -1;
                i--;
            }
        }

    }

    public void sjx2(int num) {

        for (int i = 0;       i < num;        i++) {







            for (int j = 0;           j < i;        j++) {
                System.out.print("*");
            }






            System.out.println();
        }

    }

}